/*superclasse delle altre 2*/
function Catalog (URI) {
	var domCatalog;

	this.refresh = function (callbackWait, callbackOK, callbackError) {
		am = new AjaxManager (URI,
				callbackWait,
				function (req) {
					domCatalog = req.responseXML;
					if (callbackOK)
						callbackOK (req);
				},
				callbackError);
		am.get ();
	}

	this.getNodeValue=function (nodeName){
		return domCatalog.getElementsByTagName(nodeName).item(0).firstChild.nodeValue;
	}

	this.getAttributeByElement=function (nodeVal,attName){
		return domCatalog.getElementsByTagName(nodeVal).item(0).getAttribute(attName);
	}

	this.getElementsByTagName = function (tagName) {
		return domCatalog.getElementsByTagName(tagName);
	}
}


/*classe per gestire i cataloghi del DS*/
function CatalogDs(URI){

	var catalogo = new Catalog(URI);

	this.refresh = function (callbackWait, callbackOK, callbackError) {
		catalogo.refresh (callbackWait, callbackOK, callbackError);
	}

	this.getSalva=function (){
		return catalogo.getNodeValue("salvaURI");
	}
	this.getQuery=function (){
		return catalogo.getNodeValue("queryURI");
	}
}


/*classe per i cataloghi del DF*/
function CatalogDf(URI) {
	var listLayout;
	var catalogo = new Catalog (URI);
	
	
	this.refresh = function (callbackWait, callbackOK, callbackError) {
		catalogo.refresh (callbackWait,
				function (req) {
					var url = catalogo.getAttributeByElement("global","list-layout");
					var am = new AjaxManager (url,
						null,
						function (req) {
							listLayout = req.responseXML;
							if (callbackOK)
								callbackOK (req)
						},
						null);
					am.get();
				},
				callbackError);
	}

	this.getFDoc= function (){
		return catalogo.getAttributeByElement("format","document-URI");

	}
	this.getFFrag= function (){
		return catalogo.getAttributeByElement("format","fragment-URI");
	}
	/*Ritorna il dom del file xml del layout */
	this.getFLayouts= function getFLayouts(){
		return listLayout;
	}
	this.getFName= function (){
		return catalogo.getAttributeByElement("format","posted-data");	
	}
	this.getFCType= function (){
		return catalogo.getAttributeByElement("global","type");	
	}


	this.getSpecials = function () {
		var specials = catalogo.getElementsByTagName("specials")[0];
		if (!specials)
			return undefined;
		return specials.getElementsByTagName("*");
	}
}
